<template>
    <div class="sideBar" :loading="loading">
        <p class="like">
            {{ text }}
        </p>
        <van-tabs v-model="active" background="#EEEEEE"  >
            <van-tab v-for="v in list" :key="v.id">
                <template #title>
                    <div class="sideBar-item">
                        <van-image
                            class="sideBar-img"
                            fit="cover"
                            :src="v.imgURL"
                        />
                        <p>{{ v.title }}</p>
                    </div>
                </template>
            </van-tab>
        </van-tabs>
    </div>
</template>

<script>
import { getGuessLike } from '@/api/jia/';
export default {
    name: 'slideBar',
    props: {
        text: {
            type: String,
            default: () => '猜你喜欢'
        }
    },
    data() {
        return {
            active: 0,
            list: [],
            loading: true
        };
    },
    created() {
        this.getGuessLike();
    },
    methods: {
        async getGuessLike() {
            // this.loading =true
            // this.$toast.loading({
            //     message: '加载中...',
            //   //  forbidClick: true, // 禁用背景点击
            //     duration: 0 // 持续时间，默认是 2000，如果为 0 则持续展示
            // });
            try {
                const { data } = await getGuessLike();
                //   console.log(data);
                this.list = data;
            } catch (error) {
                this.$toast('请检查网络刷新重试');
            }
            this.loading = false
        }
    }
};
</script>

<style scoped lang="scss">
.sideBar {
    .sideBar-item {
        margin-top: 10px;
        .sideBar-img {
            width: 250px;
            height: 160px;
        }
        p {
            font-size: 14px;
            color: #939393;
        }
    }
    .like {
        font-size: 30px;
        text-align: left;
        line-height: 60px;
        margin: 0;
        padding: 0;
        text-indent: 1em;
        color: rgba(16, 16, 16, 100);
    }
    /deep/.van-tabs--line .van-tabs__wrap {
        position: unset;
        height: 200px !important;
    }
    /deep/.van-tabs__line {
        position: absolute;
        bottom: 0.15rem;
        left: 0;
        z-index: 1;
        width: 0.4rem;
        height: 0.03rem;
        background-color: transparent !important;
        border-radius: 0.03rem;
    }
    /deep/.van-tabs__nav:nth-child(1) {
        padding-left: 22px !important;
    }
    /deep/.van-tab {
        padding: 0 5px !important;
    }
    /deep/.van-tabs__content {
        display: none !important;
    }
}
</style>
